package com.lnking.lnkingplace.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author sn
 * @date 2021/11/10
 * @description
 */
@Configuration
public class StaticSourceConfig implements WebMvcConfigurer {

    @Value("${upload.location}")
    String baseUploadPath;

    @Value("${upload.prefix}")
    String prefix;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(prefix + "**").addResourceLocations("file:///" + baseUploadPath);
    }
}
